<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\Controller;
use App\Repository\Uploader;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;

class UploadFileController extends Controller
{
    public function upload(Request $request)
    {
         if($request->file('file')){
            $url =$request->file('file')->store('file');
         }
         if($request->file('image')){
             $url= $request->file('images')->store('file');
         }
         return response()->json([
                'status' => 1,
                'path' => Storage::url($url)
            ]);


    }

    public function uploadUeditor(Request $request)
    {
        if ($file = $request->file('file')) {
            $url = $request->file('file')->store('file');
        }

        return Response()->json(
            [
                "state" => "SUCCESS",
                "url" =>   Storage::url($url),
                "title" => $file->getBasename(),
                "original" => $file->getClientOriginalName(),
                'type' => $file->getClientOriginalExtension(),
                'size' => $file->getClientSize(),
            ]
        );
        //Storage::disk('local')->put('file.txt', 'Contents');
    }
}
